package com.tkp.config;

import com.tkp.Interceptor.AuthenticationToKenInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @Author: duk
 * @Date: 2021/11/3 14:16
 * @Description: 注册AuthenticationInterceptor拦截器，对指定请求路径进行拦截
 */
@Configuration
public class InterceptorConfig implements WebMvcConfigurer {
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(authenticationInterceptor()).addPathPatterns("/user/**");
        registry.addInterceptor(authenticationInterceptor()).addPathPatterns("/sap/**");
    }

    @Bean
    public AuthenticationToKenInterceptor authenticationInterceptor(){
        return new AuthenticationToKenInterceptor();
    }
}
